import xbmc
import xbmcgui
import thread
import os
import time


class NotifyDialog(xbmcgui.WindowDialog) :


	def __init__(self):
		width = 300
		height = 30
		screenW = self.getWidth()
		screenH = self.getHeight()

		initX = screenW - width
		initY =  screenH - height

		label = xbmcgui.ControlLabel(initX, initY, width, height, "Press 1+2 to Connect Remote")
		back = xbmcgui.ControlImage(initX,initY ,width, height, os.getcwd() + "/background.gif")
		self.addControl(back)
		self.addControl(label)

	def onAction(self,action):
		pass
		#self.close()

	def start(self):
		thread.start_new_thread(self.isConnected,(2,))

	def isConnected(self, delay):
		home_dir = os.path.expanduser("~")
		temp_file = home_dir + "/.qlive/conference/Tmp_RemoteIsConnected.qlive"

		while not os.path.exists(temp_file) :
			time.sleep(delay)
		
		self.close()	
	
if __name__ == "__main__" :
	print "qlive > start notify dialog (main)"
	n = NotifyDialog()
	n.start()
	n.doModal()
